﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="Common.js" type="text/javascript"></script>
    <script type="text/javascript">

        BindEvent(window, "load", function (e) {

            //previousSibling nextSibling
            /*
            var varSpa = Get("spa");
            var preSib = varSpa;
            while (true) {
            preSib = preSib.previousSibling; 
            if (preSib.nodeName == "SPAN") {
            break;
            }
            }
            alert(preSib.innerHTML);
            */
            // parentNode 父元素
            /*
            var varSpa = Get("spa");
            var div = varSpa.parentNode;
            if (div.innerText) {//ie
            alert(div.innerText);
            }
            else {//ff
            alert(div.textContent);
            }
            */
            // childNodes children 子元素集合
            /*
            alert(Get("divTest").childNodes.length);
//            var childs = Get("divTest").childNodes;
//            var str = "";
//            for (var i = 0; i < childs.length; i++) {
//                str += childs[i].nodeName + "\n";
//            }
//            alert(str);
            alert(Get("divTest").children.length);
            
//            alert(Get("divTest").firstChild.nodeName);
//            alert(Get("divTest").lastChild.nodeName);*/
        });
    
    </script>
</head>
<body>
    <div id="divTest">aaa
        <span>123</span>aaaa
        <span id="spa">abc</span> bbbb
        <span>456</span>ccc
        ddd
    </div>
</body>
</html>
